<template>
  <div class="cart_footer">
    <div class="cart_icon" @click="showItems">
      <i class="iconfont icon" :class="{ default_price: totalCount > 0 }"
        >&#xe60c;</i
      >
      <span class="salses_num" v-if="totalCount > 0">{{ totalCount }}</span>
    </div>
    <div class="footer_price">
      <h3>￥{{ totalPrice }}</h3>
      <span>配送费￥4元</span>
    </div>
    <div
      class="cart_footer_show defauColor"
      :class="{ currentColor: totalPrice > 20 }"
    >
      {{ payText }}
    </div>
  </div>
</template>

<script>
import { mapState, mapGetters } from 'vuex'
export default {
  methods: {
    showItems() {
      this.$store.commit('changeShopItems')
    }
  },
  computed: {
    ...mapState(['shopLis', 'cartGoods', 'isShow']),
    ...mapGetters(['totalCount', 'totalPrice']),

    payText() {
      /* eslint-disable */
      if (this.totalPrice === 0) {
        return `￥${this.shopLis.minPrice}元起送`
      } else if (this.totalPrice < this.shopLis.minPrice) {
        return `还差${this.shopLis.minPrice - this.totalPrice}元配送`
      } else {
        return `结算`
      }
    },
    isShow() {
      if (this.totalCount === 0) {
        return false
      }
    }
  }
}
</script>

<style lang="less" scoped>
.cart_footer {
  position: fixed;
  bottom: 0;
  height: 40px;
  width: 100%;
  background-color: black;
  z-index: 99;
  .cart_icon {
    height: 40px;
    width: 40px;
    background-color: black;
    border-radius: 50%;
    text-align: center;
    line-height: 40px;
    position: absolute;
    left: 14px;
    bottom: 3px;
    padding: 6px;
    .icon {
      color: white;
      font-size: 28px;
      background-color: #999;
      display: block;
      border-radius: 50%;
    }
    .default_price {
      background-color: green;
      color: white;
      font-size: 28px;
      display: block;
      border-radius: 50%;
    }
    .salses_num {
      display: block;
      position: absolute;
      bottom: 34px;
      left: 33px;
      height: 16px;
      width: 21px;
      border-radius: 8px;
      background-color: red;
      line-height: 16px;
      text-align: center;
      color: white;
      font-size: 10px;
    }
  }
  .footer_price {
    color: white;
    margin-left: 70px;
    h3 {
      margin: 5px 3px;
      font-size: 15px;
    }
    span {
      color: #ccc;
      font-size: 11px;
    }
  }
  .cart_footer_show {
    height: 40px;
    width: 100px;
    position: absolute;
    top: 0;
    right: 0;
    line-height: 40px;
    text-align: center;
    color: white;
    font-size: 13px;
  }
  .defauColor {
    background-color: #999;
  }
  .currentColor {
    background-color: green;
  }
}
</style>
